﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.Data.Linq;
using System.ComponentModel;

namespace MRSite.Entity
{
    /// <summary>
    /// 购物车表
    /// </summary>
    [Table(Name = "customer_cart")]
    public class CustomerCart : Entity
    {
        /// <summary>
        ///
        /// </summary>
        [Column(Name = "id", IsPrimaryKey = true, CanBeNull = false, IsVersion = true)]
        public override int id { get; set; }
        
        
        /// <summary>
        ///
        /// </summary>
        [Column(Name = "user_id")]
        public int user_id { get; set; }

        /// <summary>
        ///
        /// </summary>
        [Column(Name = "user_name")]
        public string user_name { get; set; }

        /// <summary>
        ///商品id
        /// </summary>
        [Column(Name = "article_id")]
        public int article_id { get; set; }

        /// <summary>
        ///购买数量
        /// </summary>
        [Column(Name = "quantity")]
        public int quantity { get; set; }

        /// <summary>
        ///销售价
        /// </summary>
        [Column(Name = "sell_price")]
        public Decimal sell_price { get; set; }

        /// <summary>
        ///用户价
        /// </summary>
        [Column(Name = "user_price")]
        public Decimal user_price { get; set; }

        /// <summary>
        ///图片
        /// </summary>
        [Column(Name = "img_url")]
        public String img_url { get; set; }

        /// <summary>
        ///规格id
        /// </summary>
        [Column(Name = "sku_id")]
        public int sku_id { get; set; }

        /// <summary>
        /// 规格属性
        /// </summary>
       [Column(Name = "sku_name")]
        public string sku_name { get; set; }

        /// <summary>
        ///产品名称
        /// </summary>
        [Column(Name = "title")]
        public String title { get; set; }

        /// <summary>
        ///赠送积分
        /// </summary>
        [Column(Name = "point")]
        public Decimal point { get; set; }

        /// <summary>
        ///扣除积分
        /// </summary>
        [Column(Name = "sell_point")]
        public Decimal sell_point { get; set; }
        
        /// <summary>
        ///
        /// </summary>
        [Column(Name = "add_time",IsDbGenerated=true)]
        public DateTime add_time { get; set; }

        /// <summary>
        /// 店铺id
        /// </summary>
        [Column(Name = "shopid"), DefaultValue(0)]
        public int shopid { get; set; }

        /// <summary>
        /// PV值，用来给奖励
        /// </summary>
        [Column(Name = "PV")]
        public Decimal PV { get; set; }

         /// <summary>
        /// 类别id   (0:零售商城产品；1：进货/分销产品；2：新用户专享；3：自营商城)
        /// </summary>
        [Column(Name = "channel_id"), DefaultValue(0)]
        public int channel_id { get; set; }

        /// <summary>
        /// 店铺设置的优惠红包
        /// </summary>
        [Column(Name = "hongbao")]
        public Decimal hongbao { get; set; }

        /// <summary>
        ///应赠送贡献值
        /// </summary>
        [Column(Name = "score"), DefaultValue(0)]
        public decimal score { get; set; }

        /// <summary>
        /// 首购奖励 赠送红包
        /// </summary>
        [Column(Name = "hongbao_first")]
        public Decimal hongbao_first { get; set; }

        /// <summary>
        /// 首购奖励 赠送贡献值
        /// </summary>
        [Column(Name = "score_first")]
        public Decimal score_first { get; set; }
        

        private EntityRef<Product> _product;
        /// <summary>
        /// 商品,外键
        /// </summary>
        [Association(Storage = "_product", ThisKey = "article_id", OtherKey = "id")]
        public Product ProductItem
        {
            get { return this._product.Entity; }
            set { this._product.Entity = value; }
        }
    }
}
